package com.sky.service.impl;

import com.sky.service.ShopingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

@Service
public class ShopServiceImpl implements ShopingService {
    @Autowired
    RedisTemplate redisTemplate;

    public static String KEY_NAME = "shop-status";

    @Override
    public Integer getStatus() {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Integer status = Integer.parseInt(valueOperations.get(KEY_NAME).toString());
        return status;
    }

    @Override
    public void setStatus(Integer status) {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set(KEY_NAME, status);
    }
}
